package cst.a308lzm.fragmenttest308lzm.Fragment;


import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import java.util.List;

import cst.a308lzm.fragmenttest308lzm.Adapter.MyAdapter;
import cst.a308lzm.fragmenttest308lzm.Iface.ArticleListener;
import cst.a308lzm.fragmenttest308lzm.Model.ArticleModel;
import cst.a308lzm.fragmenttest308lzm.bean.ArticleBean;

import cst.a308lzm.fragmenttest308lzm.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class WeixinFragment extends Fragment implements ArticleListener {
    private View view;
    private Context context;
    private TextView tvinfo;
    private List<ArticleBean> list;
    private RecyclerView recyclerView;
    private RecyclerView.LayoutManager layoutManager;
    private MyAdapter mAdapter;

    public void onResponse(List<ArticleBean> list) {
        this.list=list;
        mAdapter.setList(list);
        mAdapter.notifyDataSetChanged();

    }

    @Override
    public void onFail(String msg) {
        Toast.makeText(context,msg,Toast.LENGTH_SHORT);

    }



    public WeixinFragment() {
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        context=getActivity();
        view=inflater.inflate(R.layout.wfragment,container,false);
       //tvinfo=(TextView)view.findViewById(R.id.);
       // tvinfo.setText("微信");
        recyclerView=(RecyclerView)view.findViewById(R.id.recyclerview);
        layoutManager=new LinearLayoutManager(context);
        recyclerView.setLayoutManager(layoutManager);
        //list=getData();
        mAdapter=new MyAdapter(context);
        mAdapter.setList(list);
        recyclerView.setAdapter(mAdapter);
        ArticleModel articleModel=new ArticleModel();
        articleModel.getResultList("article",2,"2ts2j910hv4m270hipde4a67d7",this);

        Toast.makeText(context,"加载微信",Toast.LENGTH_SHORT).show();
        return view;
    }


}
